package com.apexedu.biz.timer;

import com.apexedu.identity.entity.TSysUser;
import com.apexedu.sync.service.ISyncService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import java.util.TimerTask;

/**
 * 同步所有业务系统用户 资源 角色等信息
 * Created by ly on 2014/12/2.
 */
public class SyncAllTimerTask extends TimerTask {
    protected Log log = LogFactory.getLog(this.getClass());//日志记录

    @Override
    public void run() {
        try {
            WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
            ISyncService service = (ISyncService) wac.getBean("syncService");
            TSysUser user = new TSysUser("定时器调用");
            service.syncSystem(user, null);
        } catch (Exception e) {
            log.error("SyncAllTimerTask error : " + e);
        }
    }
}
